// 单例模式构造
// 1.声明其构造函数为私有或保护
// 2.声明类Singleton<ThreadPool>为友元
// 3.从Singleton<ThreadPool>派生出ThreadPool
#ifndef STACKTEMPLATE_H
#define STACKTEMPLATE_H
template <class T>
class Singleton
{
private:
    Singleton(const Singleton &) = delete;            // 禁用拷贝构造
    Singleton &operator=(const Singleton &) = delete; // 禁用拷贝赋值
protected:
    Singleton() {}
    virtual ~Singleton() {}

public:
    static T &instance()
    {
        static T theInstance;
        return theInstance;
    }
};
#endif // SINGLETON_H ///:~ 
//use example
/*
class MyClass : public Singleton<MyClass>
{
    //...
protected:
    friend class Singleton<MyClass>;
    //...
};
*/